home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / PDraw3.0.adf / pdraw_rex.lzh / TileSelection.pdrx < prev    next >
Text File  |  1992-06-22  |  3KB  |  158 lines

  1. /*
  2. @N
  3.  
  4. This Genie will take the current group and make copies to fill an area.
  5. */
  6. parse arg sx, sy, nrows, ncols, hsp, vsp
  7. cr     = '0a'x
  8. msg = PDSetup.rexx(2,0)
  9. units = getclip(pds_units)
  10. if msg ~= 1 then exit_msg(msg)
  11.  
  12. signal on halt
  13. signal on break_c
  14. signal on break_e
  15. signal on break_d
  16.  
  17. defhsp = .5
  18. defvsp = .5
  19.  
  20. obj = pdm_SelFirstObj()
  21. if obj = 0 then exit_msg("Select a group of objects first")
  22.  
  23. /*
  24.  * If called directly by user, not from another Genie
  25.  */
  26. if sx = '' then do
  27.  
  28.     page = pdm_GetObjPage(obj)
  29.     if page = 0 then exit_msg("You must have a page created first")
  30.  
  31.     marg    = pdm_GetPageMargins(page)
  32.     pgsize  = pdm_GetPageSize(page)
  33.     left    = word(marg, 1)
  34.     top     = word(marg, 2)
  35.     pwidth  = word(pgsize, 1) - (left + word(marg, 3))
  36.     pheight = word(pgsize, 2) - (top + word(marg, 4))
  37.  
  38.     grprect = pdm_GetObjVisSize()
  39.     grpwid  = word(grprect, 1)
  40.     grphgt  = word(grprect, 2)
  41.  
  42.     cols    = pwidth % (grpwid + defhsp)
  43.     rows    = pheight % (grphgt + defvsp)
  44.  
  45.    if units = 3 then
  46.    do
  47.        form    = "Start X:" || pdm_ConvertUnits(1, 3, left) ||cr"Start Y:" || pdm_ConvertUnits(1, 3, top) ||cr"Number of Columns:"cols||cr"Number of Rows:"rows||cr"Horizontal spacing:" || pdm_ConvertUnits(1, 3, defhsp) ||cr"Vertical spacing:"
  48.       form = form || pdm_ConvertUnits(1, 3, defvsp)
  49.    end
  50.    else
  51.        form    = "Start X:"left||cr"Start Y:"top||cr"Number of Columns:"cols||cr"Number of Rows:"rows||cr"Horizontal spacing:"defhsp||cr"Vertical spacing:"defvsp
  52.  
  53.     form    = pdm_GetForm("Enter coordinates", 8, form)
  54.     if form = '' then exit_msg()
  55.  
  56.     parse var form  sx '0a'x sy '0a'x ncols '0a'x nrows '0a'x hsp '0a'x vsp
  57.  
  58.    if units = 3 then
  59.    do
  60.       sx = pdm_ConvertUnits(3, 1, sx)
  61.       sy = pdm_ConvertUnits(3, 1, sy)
  62.       hsp = pdm_ConvertUnits(3, 1, hsp)
  63.       vsp = pdm_ConvertUnits(3, 1, vsp)
  64.    end
  65.  
  66.    if ~(datatype(sy, n) & datatype(sx, n) & datatype(ncols, n) & datatype(nrows, n) & datatype(hsp, n) & datatype(vsp, n)) then
  67.        exit_msg("Invalid Entry")
  68.  
  69.    call pdm_ShowStatus("Working..")
  70.  
  71.    grprect = pdm_GetObjVisSize()
  72.    grpwid  = word(grprect, 1) + hsp
  73.    grphgt  = word(grprect, 2) + vsp
  74.  
  75. end
  76.  
  77.  
  78. /*
  79.  * Called from Genie, use hsp, vsp as width of tile, not
  80.  * as space between tiles
  81.  */
  82. else do
  83.     if ~(datatype(sy, n) & datatype(sx, n) & datatype(ncols, n) & datatype(nrows, n) & datatype(hsp, n) & datatype(vsp, n)) then
  84.  exit_msg("Invalid Entry")
  85.  
  86.     call pdm_ShowStatus("Working..")
  87.  
  88.     grprect = pdm_GetObjVisSize()
  89.     grpwid  = hsp
  90.     grphgt  = vsp
  91. end
  92.  
  93.  
  94.  
  95. call pdm_SetObjVisPosn(, sx, sy)
  96.  
  97. counter = 1
  98.  
  99. do while obj ~= 0
  100.  
  101.     objects.counter = obj
  102.     counter = counter + 1
  103.     obj = pdm_SelNextObj(obj)
  104.  
  105. end
  106.  
  107.  
  108. col = 2
  109. yoffset = 0
  110. xoffset = grpwid
  111.  
  112. do  row = 1 to nrows
  113.  
  114.     do while col <= ncols
  115.  
  116.  do i = 1 to counter - 1
  117.  
  118.    objpos = pdm_GetObjVisPosn(objects.i)
  119.    objleft = word(objpos, 1)
  120.    objright = word(objpos, 2)
  121.  
  122.      newobj =  pdm_CloneObj(objects.i,objleft, objright, xoffset, yoffset,1,1,0)
  123.  
  124.  end
  125.  
  126.  xoffset = xoffset + grpwid
  127.  col = col + 1
  128.  
  129.     end
  130.  
  131.     yoffset = yoffset + grphgt
  132.     xoffset = 0
  133.     col     = 1
  134.  
  135. end
  136.  
  137. exit_msg()
  138.  
  139. break_d:
  140. break_e:
  141. break_c:
  142. halt:
  143.     call exit_msg("User aborted Genie!")
  144.  
  145. exit_msg: procedure expose units
  146. do
  147.     parse arg message
  148.  
  149.     if message ~= '' then
  150.     call pdm_Inform(1,message,)
  151.  
  152.     call pdm_ClearStatus()
  153.     call pdm_SetUnits(units)
  154.     call pdm_AutoUpdate(1)
  155.     exit
  156. end
  157.